package ai.zixing.mashibing.basic_class.class01;

public class Code05_BSNearLeft {
    public static int nearestIndex(int[] arr, int value) {
        int index = -1;
        if (arr == null || arr.length < 1) {
            return index;
        }
        int L = 0;
        int R = arr.length - 1;
        int mid = 0;
        while (L < R) {
            mid = L + ((R - L) >> 1);
            if (arr[mid] >= value) {
                index = mid;
                R = mid - 1;
            } else {
                L = mid + 1;
            }
        }
        return index;
    }
}
